<?php
/**
 * Created by PhpStorm.
 * User: ewen
 * Date: 4/27/21
 * Time: 9:58 AM
 */

namespace app\common\model;


class WebUser extends Common
{

    /**
     * 用户表
     */

    /**
     * 获取用户列表
     * @param array $map
     * @param int $per
     * @return \think\Paginator
     */
    public static function getUserList($map = [], $per = self::DEFAULT_PER_PAGE)
    {
        $where = [
            'id' => ['>', 0]
        ];
        isset($map['keywords']) && $map['keywords'] && $where['username|phone|nickname|email'] = ['like', '%' . $map['keywords'] . '%'];
        $list = self::field('
            id,username,phone,email,nickname,create_time,userType
            ')
            ->where($where)
            ->order('id desc')
            ->paginate($per, false, ['query' => request()->param()])
            ->each(function ($item, $key) {
                $item['userTypeName'] = $item['userType'] == 1 ? lang('normal user') : lang('airdrop user');
                return $item;
            });
        return $list;
    }
}